package com.zhai.application.cotroller;

import com.alibaba.fastjson.JSONObject;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.zhai.application.flow.context.DemonContextParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequestMapping("/test")
public class FlowTestController {

    @Resource
    private FlowExecutor flowExecutor;

    @GetMapping("/doCase")
    public JSONObject testConfig(){

        DemonContextParam param = DemonContextParam.builder()
                .id(12345678L).code("test123").name("上下文参数").build();
        LiteflowResponse response = flowExecutor.execute2Resp("chain1", null,param);

        JSONObject result = new JSONObject();

        result.put("response",response.toString());
        return result;
    }
}
